/*!
 * 人员首页 通用（请求）方法
 *  
 * 作者：王智博
 * Copyright (c) 2020/04/14
 * 
 */
/**
 * @method employeeTable 查询员工信息
 * @param   page size treeId
 * @return axios
 */
export const employeeTable = (data) => {
  return axios({
    url: `/org/employee/_search?page=${data.page}&size=${data.size}&treeId=${data.treeId}`,
    method: 'get',
  })
}
/**
 * @method employeeTableSearch 查询员工信息（支持按员工姓名模糊查询）
 * @param  page size treeId name
 * @return axios
 */
export const employeeTableSearch = (data) => {
  return axios({
    url: `/org/employee/_search?page=${data.page}&size=${data.size}&treeId=${data.treeId}&name=${data.name}`,
    method: 'get',
  })
}
/**
 * @method getPositionTable 查询指定组织下的岗位列表
 * @param  orgId treeId
 * @return axios
 */
export const getPositionTable = (data) => {
  return axios({
    url: `/org/position/${data.treeId}/positions`,
    method: 'get',
  })
}
/**
 * @method addPositionTable 新增岗位信息
 * @param  data 新增内容
 * @return axios
 */
export const addPositionTable = (data) => {
  return axios({
    url: `/org/position`,
    method: 'put',
    data,
  })
}
/**
 * @method editPositionTable 修改岗位信息
 * @param  orgId treeId
 * @return axios
 */
export const editPositionTable = (data) => {
  return axios({
    url: `/org/position`,
    method: 'post',
    data,
  })
}
/**
 * @method deltPositionTable 删除岗位信息
 * @param  orgId treeId
 * @return axios
 */
export const deltPositionTable = (data) => {
  return axios({
    url: `/org/position/${data}`,
    method: 'delete',
  })
}
/**
 * @method deleteEmployee 删除员工信息
 * @param  orgId treeId
 * @return axios
 */
export const deleteEmployee = (data) => {
  return axios({
    url: `/org/employee/${data.treeId}/${data.empId}`,
    method: 'delete',
  })
}
/**
 * @method moveEmployee 根据员工编号进行排序(当前组织下的员工排序)
 * @param  orgId treeId
 * @return axios
 */
export const moveEmployee = (data) => {
  return axios({
    url: `/org/${data.treeId}/${data.empId}/${data.type}`,
    method: 'post',
  })
}
/**
 * @method saveArchivesId 批量保存员工与组织的隶属关系
 * @param  orgId treeId
 * @return axios
 */
export const saveArchivesId = (treeId,data) => {
  return axios({
    url: `/org/employee/${treeId}`,
    method: 'post',
    data,
  })
}

/**
 * @method saveEmpIds 批量保存员工与岗位的分配关系
 * @param  orgId treeId
 * @return axios
 */
export const saveEmpIds = (positionId,data) => {
  return axios({
    url: `/org/position/batch?positionId=${positionId}`,
    method: 'post',
    data,
  })
}
